﻿namespace Microsoft.SharePoint.Client
{
    using System;
    using System.ComponentModel;

    [ScriptType("SP.FileVersionCollection", ServerTypeId="{3826e282-67a6-4861-88fb-474e8aac897b}")]
    public class FileVersionCollection : ClientObjectCollection<FileVersion>
    {
        [EditorBrowsable(EditorBrowsableState.Never)]
        public FileVersionCollection(ClientRuntimeContext Context, ObjectPath ObjectPath) : base(Context, ObjectPath)
        {
        }

        [Remote]
        public void DeleteAll()
        {
            ClientAction query = new ClientActionInvokeMethod(this, "DeleteAll", null);
            base.Context.AddQuery(query);
        }

        [Remote]
        public void DeleteByID(int vid)
        {
            ClientAction query = new ClientActionInvokeMethod(this, "DeleteByID", new object[] { vid });
            base.Context.AddQuery(query);
        }

        [Remote]
        public void DeleteByLabel(string versionlabel)
        {
            if (base.Context.ValidateOnClient)
            {
                if (versionlabel == null)
                {
                    throw ClientUtility.CreateArgumentNullException("versionlabel");
                }
                if ((versionlabel != null) && (versionlabel.Length == 0))
                {
                    throw ClientUtility.CreateArgumentException("versionlabel");
                }
            }
            ClientAction query = new ClientActionInvokeMethod(this, "DeleteByLabel", new object[] { versionlabel });
            base.Context.AddQuery(query);
        }

        protected override bool InitOnePropertyFromJson(string peekedName, JsonReader reader)
        {
            bool flag = base.InitOnePropertyFromJson(peekedName, reader);
            if (flag)
            {
                return flag;
            }
            return flag;
        }

        [Remote]
        public void RestoreByLabel(string versionlabel)
        {
            if (base.Context.ValidateOnClient)
            {
                if (versionlabel == null)
                {
                    throw ClientUtility.CreateArgumentNullException("versionlabel");
                }
                if ((versionlabel != null) && (versionlabel.Length == 0))
                {
                    throw ClientUtility.CreateArgumentException("versionlabel");
                }
            }
            ClientAction query = new ClientActionInvokeMethod(this, "RestoreByLabel", new object[] { versionlabel });
            base.Context.AddQuery(query);
        }
    }
}

